/**
 */
package ms.unicorn.dsl.unicornDSL.impl;

import java.util.Collection;

import ms.unicorn.dsl.unicornDSL.UnicornDSLPackage;
import ms.unicorn.dsl.unicornDSL.XDataFrame;
import ms.unicorn.dsl.unicornDSL.XExpression;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>XData Frame</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XDataFrameImpl#isExtensible <em>Extensible</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XDataFrameImpl#isReadonly <em>Readonly</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XDataFrameImpl#getKeys <em>Keys</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XDataFrameImpl#getExpressions <em>Expressions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XDataFrameImpl extends XExpressionImpl implements XDataFrame
{
  /**
   * The default value of the '{@link #isExtensible() <em>Extensible</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isExtensible()
   * @generated
   * @ordered
   */
  protected static final boolean EXTENSIBLE_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isExtensible() <em>Extensible</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isExtensible()
   * @generated
   * @ordered
   */
  protected boolean extensible = EXTENSIBLE_EDEFAULT;

  /**
   * The default value of the '{@link #isReadonly() <em>Readonly</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isReadonly()
   * @generated
   * @ordered
   */
  protected static final boolean READONLY_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isReadonly() <em>Readonly</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isReadonly()
   * @generated
   * @ordered
   */
  protected boolean readonly = READONLY_EDEFAULT;

  /**
   * The cached value of the '{@link #getKeys() <em>Keys</em>}' attribute list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getKeys()
   * @generated
   * @ordered
   */
  protected EList<String> keys;

  /**
   * The cached value of the '{@link #getExpressions() <em>Expressions</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExpressions()
   * @generated
   * @ordered
   */
  protected EList<XExpression> expressions;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected XDataFrameImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return UnicornDSLPackage.Literals.XDATA_FRAME;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isExtensible()
  {
    return extensible;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExtensible(boolean newExtensible)
  {
    boolean oldExtensible = extensible;
    extensible = newExtensible;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XDATA_FRAME__EXTENSIBLE, oldExtensible, extensible));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isReadonly()
  {
    return readonly;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setReadonly(boolean newReadonly)
  {
    boolean oldReadonly = readonly;
    readonly = newReadonly;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XDATA_FRAME__READONLY, oldReadonly, readonly));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<String> getKeys()
  {
    if (keys == null)
    {
      keys = new EDataTypeEList<String>(String.class, this, UnicornDSLPackage.XDATA_FRAME__KEYS);
    }
    return keys;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<XExpression> getExpressions()
  {
    if (expressions == null)
    {
      expressions = new EObjectContainmentEList<XExpression>(XExpression.class, this, UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS);
    }
    return expressions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS:
        return ((InternalEList<?>)getExpressions()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XDATA_FRAME__EXTENSIBLE:
        return isExtensible();
      case UnicornDSLPackage.XDATA_FRAME__READONLY:
        return isReadonly();
      case UnicornDSLPackage.XDATA_FRAME__KEYS:
        return getKeys();
      case UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS:
        return getExpressions();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XDATA_FRAME__EXTENSIBLE:
        setExtensible((Boolean)newValue);
        return;
      case UnicornDSLPackage.XDATA_FRAME__READONLY:
        setReadonly((Boolean)newValue);
        return;
      case UnicornDSLPackage.XDATA_FRAME__KEYS:
        getKeys().clear();
        getKeys().addAll((Collection<? extends String>)newValue);
        return;
      case UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS:
        getExpressions().clear();
        getExpressions().addAll((Collection<? extends XExpression>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XDATA_FRAME__EXTENSIBLE:
        setExtensible(EXTENSIBLE_EDEFAULT);
        return;
      case UnicornDSLPackage.XDATA_FRAME__READONLY:
        setReadonly(READONLY_EDEFAULT);
        return;
      case UnicornDSLPackage.XDATA_FRAME__KEYS:
        getKeys().clear();
        return;
      case UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS:
        getExpressions().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XDATA_FRAME__EXTENSIBLE:
        return extensible != EXTENSIBLE_EDEFAULT;
      case UnicornDSLPackage.XDATA_FRAME__READONLY:
        return readonly != READONLY_EDEFAULT;
      case UnicornDSLPackage.XDATA_FRAME__KEYS:
        return keys != null && !keys.isEmpty();
      case UnicornDSLPackage.XDATA_FRAME__EXPRESSIONS:
        return expressions != null && !expressions.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (extensible: ");
    result.append(extensible);
    result.append(", readonly: ");
    result.append(readonly);
    result.append(", keys: ");
    result.append(keys);
    result.append(')');
    return result.toString();
  }

} //XDataFrameImpl
